package pl.vanta.utils.gui.filters;

import java.io.File;
import java.io.FilenameFilter;

import javax.swing.filechooser.FileFilter;

import pl.vanta.utils.StringConstants;

public class GuiFileFilter extends FileFilter implements java.io.FileFilter, FilenameFilter
{
	private String				description;

	private java.io.FileFilter	filter;

	public GuiFileFilter(java.io.FileFilter filter, String description)
	{
		if (filter == null)
		{
			throw new IllegalArgumentException(String.format(StringConstants.CANNOT_BE_NULL, "Filter"));
		}

		this.description = description;
		this.filter = filter;
	}

	@Override
	public boolean accept(File dir, String name)
	{
		return accept(new File(dir, name));
	}

	@Override
	public boolean accept(File f)
	{
		return this.filter.accept(f);
	}

	@Override
	public String getDescription()
	{
		return this.description;
	}
}